<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/jquery-3.1.1.min.js"></script>
		<script type="text/javascript" src="js/layui/layui.js"></script>
		<link rel="stylesheet" type="text/css" href="js/layui/css/layui.css" />
	</head>
	<body class="layui-layout-body">
	<div class="layui-layout layui-layout-admin">
	  <div class="layui-header">
	    <div class="layui-logo">权限管理</div>
	    <!-- 头部区域（可配合layui已有的水平导航） -->
	     <center> <font color="white"> 欢迎进入</font> </center>
	     <div id="" style="float:right">
                <a id="overlogin"  style="color:white;font-size:20px;">退出 &nbsp;&nbsp;</a>
	     </div>
	    	
	  </div>
	  
	  <div class="layui-side layui-bg-black">
	    <div class="layui-side-scroll">
	      <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
		  <ul id="menutree"></ul>
	    </div>
	  </div>
	  
	  <div class="layui-body">
	    <!-- 内容主体区域 -->
		<div class="layui-tab app-container" lay-filter="tabs" lay-allowClose="true">
			<ul class="layui-tab-title custom-tab"></ul>
			<div class="layui-tab-content" ></div>
		</div>
	  </div>
	  
	</div>
	<script type="text/javascript">
	var token = window.localStorage.getItem("token");
	var Stringname="";
	//alert(token);
	if(token==""||token==null){
		window.location="login.html";
	}
		var roleNames = window.localStorage.getItem("roleNames");
		var roleName = roleNames.split(",");
			
		$(function(){
			$.ajax({
				url:"/GetSysRightsJsonLayUI",
				data:{
					roleNames:roleName,
					token:token
				},
				dataType:"json",
				type:"post",
				success:function(res){
					//console.log(res)
					if(res.success==false){
						if(res.message==0){
							alert(res.remark);
							window.location="login.html";
						}else{
							alert(res.remark);
						}
					}
					layui.use(['tree','element'],function(){
						var element = layui.element;
						var tree = layui.tree;
						tree.render({
							elem:"#menutree",
							data:res,
							//accordion:true,
							showLine:false,
							click: function(obj){
								var node = obj.data;
								var exist = $("li[lay-id='" + node.id + "']").length;//判断是不是用重复的选项卡
								if (exist > 0) {
									element.tabChange('tabs', node.id);// 切换到已有的选项卡
								} else {
									if (node.href != null && node.href != "") {// 判断是否需要新增选项卡
										element.tabAdd(
											'tabs',
											{
												title: node.title,
												content: '<iframe   scrolling="yes" frameborder="0" src=" '
												+ node.href
												+ ' " width="100%;" height="545px;"></iframe>'// 支持传入html
												,
												// width="99%" height="99%"
												id: node.id
											});
										element.tabChange('tabs', node.id);
									}
								}
								
							}
						});
					})
				}
			})
				  $("#overlogin").click(function(){
				   layui.use(['table','layer','form', 'laydate'],function(){
					var table = layui.table;
					var form = layui.form;
					var laydate = layui.laydate;
				  layer.confirm('确认要注销账户吗？', {
			          btn : [ '确定', '取消' ]//按钮
			      }, function(index) {
			    	  //alert("注销");
			    	  $.post("/logout",{
								   	},function(res){
								   			layer.msg("注销成功!",function(){
								   				window.localStorage.clear();
												window.location = 'login.html';
								   			});
								   	},"json");
			      		});
				   })  
			  })
		})
	</script>
	</body>
</html>
